# coding: utf-8

from PIL import Image
from handler.image import *

image = Image.open('/home/yehun/Projects/gitProjects/policy-crawls/train/source/0a298a4d-d2a3-4fdb-bd42-e387921b58f0.jpg')
image = image.convert('L')
image = image.convert('1')
for x in range(1, (image.size[0] - 1)):
    for y in range(1, (image.size[1] - 1)):
        if image.getpixel((x, y)) == 0 \
                and image.getpixel(((x - 1), (y + 1))) == 255 \
                and image.getpixel(((x - 1), y)) == 255 \
                and image.getpixel(((x - 1), (y - 1))) == 255 \
                and image.getpixel(((x + 1), (y + 1))) == 255 \
                and image.getpixel(((x + 1), y)) == 255 \
                and image.getpixel(((x + 1), (y - 1))) == 255 \
                and image.getpixel((x ,(y + 1))) == 255 \
                and image.getpixel((x ,(y - 1))) == 255:
            image.putpixel([x, y], 255)
image.show()
print image_to_ascii(image)
print image_to_string(image)

# print np.zeros((1, 10))
# print np.sqrt(20)
# np.random.seed(0)
# print np.random.rand(10)